class KeyHandler
 	def initialize(presen)
 	  @presen = presen
  end
  
  key_actions = { 
    :VK_RIGHT => :next_page,
    :VK_LEFT => :prev_page,
    :VK_F => :first_page,
    :VK_E => :last_page,
    :VK_Q => :quit,
    :VK_R => :load, # reload
    :VK_L => :large,
    :VK_S => :small
  }
  
  KEY_ACTIONS = key_actions.inject({}) do |dest, (key, action)|
    dest[java.awt.event.KeyEvent.const_get(key)] = action
    dest
  end
  
  def keyPressed event
    action = KEY_ACTIONS[event.get_key_code]
    @presen.send(action) if action
    @presen.change_color(:DARK_GRAY)
  end
  
  def keyTyped event
    @presen.change_color(:GRAY)
  end
  
  def keyReleased event
    @presen.change_color(:WHITE)
    @presen.do_extention
  end
end
